const express = require("express");
const mongoose = require("mongoose");

// 引入 UserRouter
const UserRouter = require("./routes/user.js");
// 引入 FilmRouter
const FilmRouter = require("./routes/film.js");

const app = express();

// 注册中间件，让 req.body 有值
app.use(express.json());
app.use(express.urlencoded());

// 注册路由模块中间件
app.use(UserRouter);
app.use(FilmRouter);

async function main() {
  await mongoose.connect("mongodb://127.0.0.1:27017/maizuo");

  app.listen(3000, () => {
    console.log("服务启动成功");
  });
}

main();
